package lab02.test17;

public class ArrayMaximum  implements Extremum {
    int max;
    int maxLocation;     //数组中最大值的位置和值

    @Override
    public void getExtrtmum(int[] array) {
        max = array[0];
        maxLocation = -1;
        for (int i = 0; i < array.length; i++) {
            if (array[i] > max) {
                max = array[i];
                maxLocation = i;
            }
        }
        System.out.println("最大值:" + max);
        System.out.println("最大值的位置:" + "第" + (maxLocation + 1) + "个数.");
    }
}
